package com.yalisanda.edu.controller;


import com.yalisanda.edu.entity.EduStudent;
import com.yalisanda.edu.entity.vo.*;
import com.yalisanda.edu.service.EduStudentService;
import org.springframework.web.bind.annotation.*;
import org.ylsdxy.model.response.CustomPage;
import org.ylsdxy.model.response.ResponseResult;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/edustudent")
public class StudentController {
    @Resource
    private EduStudentService eduStudentService;


    /*
     * 添加学生
     * */
    @PostMapping("/insertStudent")
    public ResponseResult<Boolean> insertStudent(@RequestBody EduStudent eduStudent) {
        return new ResponseResult<Boolean>(ResponseResult.SUCCESS, "success", eduStudentService.insertStudent(eduStudent));
    }

    /*
     * 查询学生来源
     * */
    @GetMapping("/findResource")
    public ResponseResult<List<EduStudentSourceVo>> getResource() {
        return new ResponseResult<>(ResponseResult.SUCCESS, "success", eduStudentService.findResource());
    }

    /*
     * 按日期分组查询报名人数
     * */
    @GetMapping("/findCountGroupByDate")
    public ResponseResult<List<StudentCountGroupByDateVo>> getCountGroupByDate() {
        return new ResponseResult<>(ResponseResult.SUCCESS, "success", eduStudentService.findCountGroupByDate());
    }

    @GetMapping("/findEduStudentByPage/{page}/{size}")
    public ResponseResult<CustomPage<List<EduStudent>>> findEduStudentByPage(@PathVariable("page") int page, @PathVariable("size") int size) {
        return new ResponseResult<>(ResponseResult.SUCCESS, "success", eduStudentService.findEduStudentByPage(page, size));
    }

    @GetMapping("/findEduStudentById/{id}")
    public ResponseResult<EduStudent> findEduStudentById(@PathVariable("id") Integer id) {
        return new ResponseResult<>(ResponseResult.SUCCESS, "success", eduStudentService.findEduStudentById(id));
    }

    @GetMapping("/findEduStudentCourseInfoByStuId/{stuId}")
    public ResponseResult<EduStudentCourseInfoVo> findEduStudentCourseInfoByStuId(@PathVariable("stuId") Integer stuId) {
        return new ResponseResult<>(ResponseResult.SUCCESS, "success", eduStudentService.findEduStudentCourseInfoByStuId(stuId));
    }

    @GetMapping("/findEduStudentOrderByStuId/{id}")
    public ResponseResult<EduStudentOrderVo> findEduStudentOrderByStuId(@PathVariable("id") Integer stuId) {
        return new ResponseResult<>(ResponseResult.SUCCESS, "success", eduStudentService.findEduStudentOrderByStuId(stuId));
    }

    @GetMapping("/findEduSignedConditionByStuId/{id}")
    public ResponseResult<SignedConditionVo> findEduSignedConditionByStuId(@PathVariable("id")Integer stuId){
        return new ResponseResult<>(ResponseResult.SUCCESS,"success",eduStudentService.findEduSignedConditionByStuId(stuId));
    }
}
